//
//  BookingEditTimeCell.m
//  JustMeeting
//
//  Created by 孙晓奇 on 15/12/16.
//  Copyright © 2015年 sunny. All rights reserved.
//

#import "BookingEditTimeCell.h"

@interface BookingEditTimeCell()
@property (strong, nonatomic) IBOutlet UILabel *timeLabel;
@property (strong, nonatomic) IBOutlet UILabel *durationLabel;
@property (strong, nonatomic) IBOutlet UIButton *extendBtn1;
@property (strong, nonatomic) IBOutlet UIButton *extendBtn2;
@end

@implementation BookingEditTimeCell

- (void)awakeFromNib {
    // Initialization code
    self.extendBtn1.layer.borderWidth = 1;
    self.extendBtn1.layer.borderColor = [UIColor colorWithHexString:@"666666"].CGColor;
    self.extendBtn1.layer.masksToBounds = YES;
    self.extendBtn1.layer.cornerRadius = 5.0;
    
    self.extendBtn2.layer.borderWidth = 1;
    self.extendBtn2.layer.borderColor = [UIColor colorWithHexString:@"666666"].CGColor;
    self.extendBtn2.layer.masksToBounds = YES;
    self.extendBtn2.layer.cornerRadius = 5.0;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@synthesize time = _time;
@synthesize duration = _duration;

-(void)setTime:(NSString *)time{
    _time = time;
    self.timeLabel.text = time;
}

-(void)setDuration:(NSString *)duration{
    _duration = duration;
    self.durationLabel.text = duration;
}

- (IBAction)extendMeetingTime:(UIButton *)sender {    
    sender.selected = !sender.selected;
    [self extendBtn:sender colorHighlighted:sender.selected];
    //延长30min
    if (sender == self.extendBtn1) {
        self.extendBtn2.selected = NO;
        [self extendBtn:self.extendBtn2 colorHighlighted:NO];
        NSTimeInterval extend = sender.selected? 30 * 60: 0;
        [self.delegate tableViewCell:self extendMeeting: extend];
    }
    //延长60min
    else if(sender == self.extendBtn2){
        self.extendBtn1.selected = NO;
        [self extendBtn:self.extendBtn1 colorHighlighted:NO];
        NSTimeInterval extend = sender.selected? 60 * 60: 0;
        [self.delegate tableViewCell:self extendMeeting: extend];
    }
}

-(void)extendBtn:(UIButton *)btn colorHighlighted:(BOOL)selected{
    btn.layer.borderColor = (selected? [UIColor colorWithHexString:@"1182bb"] : [UIColor colorWithHexString:@"666666"]).CGColor;
    btn.backgroundColor = selected? [UIColor colorWithHexString:@"1182bb"] : [UIColor clearColor];
}

@end
